#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
AI降本增效：大型企业项目管理中的应用 PPT生成脚本

使用说明：
1. 首先安装必要的依赖：pip install python-pptx
2. 运行此脚本：python generate_ppt.py
3. 脚本将生成名为 'AI降本增效_企业项目管理应用.pptx' 的演示文稿
"""

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.text import MSO_ANCHOR, MSO_AUTO_SIZE
from pptx.dml.color import RGBColor
from pptx.enum.shapes import MSO_SHAPE
from pptx.enum.dml import MSO_THEME_COLOR
# 幻灯片布局直接通过prs.slide_layouts[index]访问
# 可用布局索引及名称:
# 0: Title Slide
# 1: Title and Content
# 2: Section Header
# 3: Two Content
# 4: Comparison
# 5: Title Only
# 6: Blank
# 7: Content with Caption
# 8: Picture with Caption
# 9: Title and Vertical Text
# 10: Vertical Title and Text
# 已删除不必要的PP_SLIDE_LAYOUT导入语句

# 创建演示文稿对象并应用主题
prs = Presentation()

# 应用内置主题 (1-48为不同主题)
# 注：python-pptx实际上不直接支持通过API设置主题
# 我们将通过自定义颜色、字体和效果来模拟专业主题

# 设置幻灯片尺寸为16:9宽屏
prs.slide_width = Inches(16)
prs.slide_height = Inches(9)

# 定义专业主题颜色方案
COLOR_PRIMARY = RGBColor(0, 51, 102)  # 深蓝主色
COLOR_SECONDARY = RGBColor(0, 120, 215)  # 亮蓝辅助色
COLOR_ACCENT = RGBColor(255, 102, 0)  # 橙色强调色
COLOR_TEXT = RGBColor(33, 33, 33)  # 深灰文本
COLOR_TEXT_LIGHT = RGBColor(102, 102, 102)  # 浅灰文本
COLOR_BACKGROUND = RGBColor(255, 255, 255)  # 白色背景
COLOR_BACKGROUND_ALT = RGBColor(245, 247, 250)  # 浅蓝灰背景

# 定义字体方案
FONT_HEADING = '微软雅黑'
FONT_BODY = '微软雅黑'

# 添加公司Logo位置 (可替换为实际Logo路径)
LOGO_PATH = None  # 'company_logo.png'


def create_title_slide(title, subtitle, footer):
    """创建标题幻灯片"""
    slide_layout = prs.slide_layouts[0]  # 标题幻灯片布局
    slide = prs.slides.add_slide(slide_layout)
    title_placeholder = slide.shapes.title
    subtitle_placeholder = slide.placeholders[1]

    # 添加背景渐变效果
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND_ALT

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_PRIMARY

    # 设置标题
    title_placeholder.text = title
    title_placeholder.text_frame.paragraphs[0].font.size = Pt(44)
    title_placeholder.text_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_placeholder.text_frame.paragraphs[0].font.name = FONT_HEADING
    title_placeholder.text_frame.paragraphs[0].font.bold = True

    # 设置副标题
    subtitle_placeholder.text = subtitle
    subtitle_placeholder.text_frame.paragraphs[0].font.size = Pt(28)
    subtitle_placeholder.text_frame.paragraphs[0].font.color.rgb = COLOR_SECONDARY
    subtitle_placeholder.text_frame.paragraphs[0].font.name = FONT_BODY

    # 添加公司Logo
    if LOGO_PATH:
        logo_left = Inches(13)
        logo_top = Inches(7)
        logo_width = Inches(2)
        logo_height = Inches(1)
        slide.shapes.add_picture(LOGO_PATH, logo_left, logo_top, logo_width, logo_height)

    # 添加页脚
    footer_placeholder = slide.shapes.add_textbox(Inches(0.5), Inches(8.0), Inches(15), Inches(0.5))
    footer_text = footer_placeholder.text_frame.add_paragraph()
    footer_text.text = footer
    footer_text.font.size = Pt(14)
    footer_text.font.color.rgb = COLOR_TEXT_LIGHT
    footer_text.font.name = FONT_BODY

    return slide


def create_section_slide(title, content_list):
    """创建章节幻灯片"""
    slide_layout = prs.slide_layouts[1]  # 标题和内容布局
    slide = prs.slides.add_slide(slide_layout)
    title_placeholder = slide.shapes.title
    content_placeholder = slide.placeholders[1]

    # 添加背景
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_SECONDARY

    # 设置标题
    title_placeholder.text = title
    title_placeholder.text_frame.paragraphs[0].font.size = Pt(36)
    title_placeholder.text_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_placeholder.text_frame.paragraphs[0].font.name = FONT_HEADING
    title_placeholder.text_frame.paragraphs[0].font.bold = True

    # 自定义内容占位符样式
    content_placeholder.fill.solid()
    content_placeholder.fill.fore_color.rgb = COLOR_BACKGROUND_ALT
    content_placeholder.line.color.rgb = COLOR_SECONDARY
    content_placeholder.line.width = Pt(1)

    # 设置内容
    for item in content_list:
        p = content_placeholder.text_frame.add_paragraph()
        p.text = item
        p.font.size = Pt(20)
        p.font.color.rgb = COLOR_TEXT
        p.font.name = FONT_BODY
        p.level = 0
        p.space_after = Pt(12)

    # 添加页码
    page_num = slide.slide_id
    page_num_box = slide.shapes.add_textbox(Inches(15), Inches(8.0), Inches(1), Inches(0.5))
    page_num_text = page_num_box.text_frame.add_paragraph()
    page_num_text.text = f"{page_num}"
    page_num_text.font.size = Pt(14)
    page_num_text.font.color.rgb = COLOR_TEXT_LIGHT
    page_num_text.font.name = FONT_BODY
    page_num_text.alignment = 2  # 右对齐

    return slide


def create_content_slide(title, content_dict):
    """创建内容幻灯片"""
    slide_layout = prs.slide_layouts[1]  # 标题和内容布局
    slide = prs.slides.add_slide(slide_layout)
    title_placeholder = slide.shapes.title

    # 添加背景
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_SECONDARY

    # 设置标题
    title_placeholder.text = title
    title_placeholder.text_frame.paragraphs[0].font.size = Pt(32)
    title_placeholder.text_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_placeholder.text_frame.paragraphs[0].font.name = FONT_HEADING
    title_placeholder.text_frame.paragraphs[0].font.bold = True

    # 添加内容区域背景
    content_bg_left = Inches(0.5)
    content_bg_top = Inches(1.8)
    content_bg_width = Inches(15)
    content_bg_height = Inches(6.5)
    content_bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, content_bg_left, content_bg_top, content_bg_width, content_bg_height
    )
    content_bg.fill.solid()
    content_bg.fill.fore_color.rgb = COLOR_BACKGROUND_ALT
    content_bg.line.color.rgb = COLOR_SECONDARY
    content_bg.line.width = Pt(1)
    content_bg.z_order = -1  # 置于底层

    # 添加内容
    left = Inches(1.0)
    top = Inches(2.0)
    width = Inches(14.0)
    height = Inches(6.0)

    content_box = slide.shapes.add_textbox(left, top, width, height)
    text_frame = content_box.text_frame
    text_frame.word_wrap = True

    for section_title, points in content_dict.items():
        # 添加章节标题
        p = text_frame.add_paragraph()
        p.text = section_title
        p.font.size = Pt(24)
        p.font.bold = True
        p.font.color.rgb = COLOR_SECONDARY
        p.font.name = FONT_HEADING
        p.space_after = Pt(15)

        # 添加要点
        for point in points:
            p = text_frame.add_paragraph()
            p.text = point
            p.font.size = Pt(18)
            p.font.color.rgb = COLOR_TEXT
            p.font.name = FONT_BODY
            p.level = 1
            p.space_after = Pt(8)

    # 添加页码
    page_num = slide.slide_id
    page_num_box = slide.shapes.add_textbox(Inches(15), Inches(8.0), Inches(1), Inches(0.5))
    page_num_text = page_num_box.text_frame.add_paragraph()
    page_num_text.text = f"{page_num}"
    page_num_text.font.size = Pt(14)
    page_num_text.font.color.rgb = COLOR_TEXT_LIGHT
    page_num_text.font.name = FONT_BODY
    page_num_text.alignment = 2  # 右对齐

    return slide


def create_case_slide(title, cases):
    """创建案例分析幻灯片"""
    slide_layout = prs.slide_layouts[5]  # 空白布局
    slide = prs.slides.add_slide(slide_layout)

    # 添加背景
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_SECONDARY

    # 添加标题
    title_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.5), Inches(15), Inches(1.0))
    title_frame = title_box.text_frame
    title_frame.paragraphs[0].text = title
    title_frame.paragraphs[0].font.size = Pt(32)
    title_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_frame.paragraphs[0].font.bold = True
    title_frame.paragraphs[0].font.name = FONT_HEADING

    # 添加案例卡片容器背景
    container_left = Inches(0.5)
    container_top = Inches(1.8)
    container_width = Inches(15.0)
    container_height = Inches(6.5)
    container = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, container_left, container_top, container_width, container_height
    )
    container.fill.solid()
    container.fill.fore_color.rgb = COLOR_BACKGROUND_ALT
    container.line.color.rgb = COLOR_SECONDARY
    container.line.width = Pt(1)
    container.z_order = -1  # 置于底层

    # 添加案例卡片
    left = Inches(0.5)
    top = Inches(1.8)
    width = Inches(15.0)
    height = Inches(6.5)

    for i, (case_title, case_content) in enumerate(cases.items()):
        # 计算位置
        card_left = left + (i % 2) * (width / 2 + Inches(0.2))
        card_top = top + (i // 2) * (height / 2 + Inches(0.2))
        card_width = width / 2 - Inches(0.2)
        card_height = height / 2 - Inches(0.2)

        # 添加卡片背景
        card = slide.shapes.add_shape(
            MSO_SHAPE.RECTANGLE, card_left, card_top, card_width, card_height
        )
        card.fill.solid()
        card.fill.fore_color.rgb = COLOR_BACKGROUND
        card.line.color.rgb = COLOR_SECONDARY
        card.line.width = Pt(1.5)
        # 添加轻微阴影效果
        card.shadow.inherit = False
        card.shadow.type = 1
        card.shadow.blur_radius = Pt(5)
        card.shadow.offset_x = Pt(2)
        card.shadow.offset_y = Pt(2)
        # 注意：当前版本pptx库不支持设置阴影颜色

        # 添加卡片标题
        title_left = card_left + Inches(0.2)
        title_top = card_top + Inches(0.2)
        title_width = card_width - Inches(0.4)
        title_height = Inches(0.6)

        title_box = slide.shapes.add_textbox(title_left, title_top, title_width, title_height)
        title_frame = title_box.text_frame
        title_frame.paragraphs[0].text = case_title
        title_frame.paragraphs[0].font.size = Pt(20)
        title_frame.paragraphs[0].font.bold = True
        title_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
        title_frame.paragraphs[0].font.name = FONT_HEADING

        # 添加卡片内容
        content_left = card_left + Inches(0.2)
        content_top = card_top + Inches(0.8)
        content_width = card_width - Inches(0.4)
        content_height = card_height - Inches(1.0)

        content_box = slide.shapes.add_textbox(content_left, content_top, content_width, content_height)
        content_frame = content_box.text_frame
        content_frame.word_wrap = True

        for point in case_content:
            p = content_frame.add_paragraph()
            p.text = point
            p.font.size = Pt(16)
            p.font.color.rgb = COLOR_TEXT
            p.font.name = FONT_BODY
            p.level = 0
            p.space_after = Pt(5)

    # 添加页码
    page_num = slide.slide_id
    page_num_box = slide.shapes.add_textbox(Inches(15), Inches(8.0), Inches(1), Inches(0.5))
    page_num_text = page_num_box.text_frame.add_paragraph()
    page_num_text.text = f"{page_num}"
    page_num_text.font.size = Pt(14)
    page_num_text.font.color.rgb = COLOR_TEXT_LIGHT
    page_num_text.font.name = FONT_BODY
    page_num_text.alignment = 2  # 右对齐

    return slide


def create_challenge_solution_slide(title, challenges_solutions):
    """创建挑战与解决方案幻灯片"""
    slide_layout = prs.slide_layouts[5]  # 空白布局
    slide = prs.slides.add_slide(slide_layout)

    # 添加背景
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_SECONDARY

    # 添加标题
    title_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.5), Inches(15), Inches(1.0))
    title_frame = title_box.text_frame
    title_frame.paragraphs[0].text = title
    title_frame.paragraphs[0].font.size = Pt(32)
    title_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_frame.paragraphs[0].font.bold = True
    title_frame.paragraphs[0].font.name = FONT_HEADING

    # 添加挑战与解决方案容器
    left = Inches(0.5)
    top = Inches(1.8)
    width = Inches(15.0)
    height = Inches(6.5)

    container = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, left, top, width, height
    )
    container.fill.solid()
    container.fill.fore_color.rgb = COLOR_BACKGROUND_ALT
    container.line.color.rgb = COLOR_SECONDARY
    container.line.width = Pt(1)
    container.z_order = -1  # 置于底层

    # 挑战部分
    challenge_left = left
    challenge_top = top
    challenge_width = width / 2 - Inches(0.2)
    challenge_height = height

    challenge_box = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, challenge_left, challenge_top, challenge_width, challenge_height
    )
    challenge_box.fill.solid()
    challenge_box.fill.fore_color.rgb = COLOR_BACKGROUND
    challenge_box.line.color.rgb = COLOR_ACCENT
    challenge_box.line.width = Pt(1.5)
    # 添加轻微阴影效果
    challenge_box.shadow.inherit = False
    challenge_box.shadow.type = 1
    challenge_box.shadow.blur_radius = Pt(5)
    challenge_box.shadow.offset_x = Pt(2)
    challenge_box.shadow.offset_y = Pt(2)
    # 注意：当前版本pptx库不支持设置阴影颜色

    # 挑战标题
    challenge_title_box = slide.shapes.add_textbox(challenge_left + Inches(0.2), challenge_top + Inches(0.2), challenge_width - Inches(0.4), Inches(0.6))
    challenge_title_frame = challenge_title_box.text_frame
    challenge_title_frame.paragraphs[0].text = "挑战"
    challenge_title_frame.paragraphs[0].font.size = Pt(24)
    challenge_title_frame.paragraphs[0].font.bold = True
    challenge_title_frame.paragraphs[0].font.color.rgb = COLOR_ACCENT
    challenge_title_frame.paragraphs[0].font.name = FONT_HEADING

    # 挑战内容
    challenge_content_box = slide.shapes.add_textbox(challenge_left + Inches(0.2), challenge_top + Inches(0.8), challenge_width - Inches(0.4), challenge_height - Inches(1.0))
    challenge_content_frame = challenge_content_box.text_frame
    challenge_content_frame.word_wrap = True

    # 解决方案部分
    solution_left = left + width / 2 + Inches(0.2)
    solution_top = top
    solution_width = width / 2 - Inches(0.2)
    solution_height = height

    solution_box = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, solution_left, solution_top, solution_width, solution_height
    )
    solution_box.fill.solid()
    solution_box.fill.fore_color.rgb = COLOR_BACKGROUND
    solution_box.line.color.rgb = COLOR_PRIMARY
    solution_box.line.width = Pt(1.5)
    # 添加轻微阴影效果
    solution_box.shadow.inherit = False
    solution_box.shadow.type = 1
    solution_box.shadow.blur_radius = Pt(5)
    solution_box.shadow.offset_x = Pt(2)
    solution_box.shadow.offset_y = Pt(2)
    # 注意：当前版本pptx库不支持设置阴影颜色

    # 解决方案标题
    solution_title_box = slide.shapes.add_textbox(solution_left + Inches(0.2), solution_top + Inches(0.2), solution_width - Inches(0.4), Inches(0.6))
    solution_title_frame = solution_title_box.text_frame
    solution_title_frame.paragraphs[0].text = "解决方案"
    solution_title_frame.paragraphs[0].font.size = Pt(24)
    solution_title_frame.paragraphs[0].font.bold = True
    solution_title_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    solution_title_frame.paragraphs[0].font.name = FONT_HEADING

    # 解决方案内容
    solution_content_box = slide.shapes.add_textbox(solution_left + Inches(0.2), solution_top + Inches(0.8), solution_width - Inches(0.4), solution_height - Inches(1.0))
    solution_content_frame = solution_content_box.text_frame
    solution_content_frame.word_wrap = True

    # 填充内容
    for i, (challenge, solution) in enumerate(challenges_solutions.items()):
        # 添加挑战
        p = challenge_content_frame.add_paragraph()
        p.text = f"{i+1}. {challenge}"
        p.font.size = Pt(18)
        p.font.color.rgb = COLOR_TEXT
        p.font.name = FONT_BODY
        p.level = 0
        p.space_after = Pt(10)

        # 添加解决方案
        p = solution_content_frame.add_paragraph()
        p.text = f"{i+1}. {solution}"
        p.font.size = Pt(18)
        p.font.color.rgb = COLOR_TEXT
        p.font.name = FONT_BODY
        p.level = 0
        p.space_after = Pt(10)

    # 添加页码
    page_num = slide.slide_id
    page_num_box = slide.shapes.add_textbox(Inches(15), Inches(8.0), Inches(1), Inches(0.5))
    page_num_text = page_num_box.text_frame.add_paragraph()
    page_num_text.text = f"{page_num}"
    page_num_text.font.size = Pt(14)
    page_num_text.font.color.rgb = COLOR_TEXT_LIGHT
    page_num_text.font.name = FONT_BODY
    page_num_text.alignment = 2  # 右对齐

    return slide


def create_summary_slide(title, summary_points):
    """创建总结幻灯片"""
    slide_layout = prs.slide_layouts[1]  # 标题和内容布局
    slide = prs.slides.add_slide(slide_layout)
    title_placeholder = slide.shapes.title
    content_placeholder = slide.placeholders[1]

    # 添加背景
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_SECONDARY

    # 设置标题
    title_placeholder.text = title
    title_placeholder.text_frame.paragraphs[0].font.size = Pt(36)
    title_placeholder.text_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_placeholder.text_frame.paragraphs[0].font.name = FONT_HEADING
    title_placeholder.text_frame.paragraphs[0].font.bold = True

    # 自定义内容占位符样式
    content_placeholder.fill.solid()
    content_placeholder.fill.fore_color.rgb = COLOR_BACKGROUND_ALT
    content_placeholder.line.color.rgb = COLOR_SECONDARY
    content_placeholder.line.width = Pt(1)

    # 设置内容
    for i, point in enumerate(summary_points):
        p = content_placeholder.text_frame.add_paragraph()
        p.text = f"{i+1}. {point}"
        p.font.size = Pt(24)
        p.font.color.rgb = COLOR_TEXT
        p.font.name = FONT_BODY
        p.level = 0
        p.space_after = Pt(15)

    # 添加页码
    page_num = slide.slide_id
    page_num_box = slide.shapes.add_textbox(Inches(15), Inches(8.0), Inches(1), Inches(0.5))
    page_num_text = page_num_box.text_frame.add_paragraph()
    page_num_text.text = f"{page_num}"
    page_num_text.font.size = Pt(14)
    page_num_text.font.color.rgb = COLOR_TEXT_LIGHT
    page_num_text.font.name = FONT_BODY
    page_num_text.alignment = 2  # 右对齐

    return slide


def create_qa_slide(title):
    """创建问答幻灯片"""
    slide_layout = prs.slide_layouts[5]  # 空白布局
    slide = prs.slides.add_slide(slide_layout)

    # 添加背景
    background = slide.background
    fill = background.fill
    fill.solid()
    fill.fore_color.rgb = COLOR_BACKGROUND_ALT

    # 添加装饰条
    decor_left = Inches(0)
    decor_top = Inches(0)
    decor_width = Inches(0.5)
    decor_height = Inches(9)
    decor_shape = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, decor_left, decor_top, decor_width, decor_height
    )
    decor_shape.fill.solid()
    decor_shape.fill.fore_color.rgb = COLOR_PRIMARY

    # 添加标题背景板
    title_bg_left = Inches(2)
    title_bg_top = Inches(2.5)
    title_bg_width = Inches(12)
    title_bg_height = Inches(3)
    title_bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, title_bg_left, title_bg_top, title_bg_width, title_bg_height
    )
    title_bg.fill.solid()
    title_bg.fill.fore_color.rgb = COLOR_BACKGROUND
    title_bg.line.color.rgb = COLOR_PRIMARY
    title_bg.line.width = Pt(2)
    # 添加轻微阴影效果
    title_bg.shadow.inherit = False
    title_bg.shadow.type = 1
    title_bg.shadow.blur_radius = Pt(10)
    title_bg.shadow.offset_x = Pt(5)
    title_bg.shadow.offset_y = Pt(5)
    # 注意：当前版本pptx库不支持设置阴影颜色

    # 添加标题
    title_box = slide.shapes.add_textbox(Inches(0.5), Inches(3.5), Inches(15), Inches(2.0))
    title_frame = title_box.text_frame
    title_frame.paragraphs[0].text = title
    title_frame.paragraphs[0].font.size = Pt(48)
    title_frame.paragraphs[0].font.color.rgb = COLOR_PRIMARY
    title_frame.paragraphs[0].font.bold = True
    title_frame.paragraphs[0].font.name = FONT_HEADING
    title_frame.paragraphs[0].alignment = 1  # 居中

    # 添加提示文字
    hint_box = slide.shapes.add_textbox(Inches(0.5), Inches(6.0), Inches(15), Inches(1.0))
    hint_frame = hint_box.text_frame
    hint_frame.paragraphs[0].text = "感谢聆听，欢迎提问"
    hint_frame.paragraphs[0].font.size = Pt(24)
    hint_frame.paragraphs[0].font.color.rgb = COLOR_SECONDARY
    hint_frame.paragraphs[0].font.name = FONT_BODY
    hint_frame.paragraphs[0].alignment = 1  # 居中

    # 添加页码
    page_num = slide.slide_id
    page_num_box = slide.shapes.add_textbox(Inches(15), Inches(8.0), Inches(1), Inches(0.5))
    page_num_text = page_num_box.text_frame.add_paragraph()
    page_num_text.text = f"{page_num}"
    page_num_text.font.size = Pt(14)
    page_num_text.font.color.rgb = COLOR_TEXT_LIGHT
    page_num_text.font.name = FONT_BODY
    page_num_text.alignment = 2  # 右对齐

    # 添加公司Logo
    if LOGO_PATH:
        logo_left = Inches(13)
        logo_top = Inches(1)
        logo_width = Inches(2)
        logo_height = Inches(1)
        slide.shapes.add_picture(LOGO_PATH, logo_left, logo_top, logo_width, logo_height)

    return slide

# 创建幻灯片
# 1. 封面页
create_title_slide(
    "AI驱动的降本增效：大型企业项目管理的新范式",
    "从案例到实践的全面解析",
    "[日期] | [演讲者姓名]"
)

# 2. 目录页
create_section_slide(
    "目录",
    [
        "1. 背景与趋势：AI赋能企业项目管理",
        "2. 核心价值：AI如何实现降本增效",
        "3. 行业实践：多领域案例分析",
        "4. 实施路径：从规划到落地",
        "5. 挑战与解决方案",
        "6. 未来展望",
        "7. 总结"
    ]
)

# 3. 背景与趋势
create_content_slide(
    "背景与趋势：AI赋能企业项目管理",
    {
        "当今企业面临的挑战": [
            "成本压力持续上升",
            "效率提升需求迫切",
            "复杂项目管理难度加大"
        ],
        "AI技术的成熟": [
            "大模型技术进入实用阶段",
            "RPA流程自动化广泛应用",
            "知识图谱实现深度关联分析"
        ],
        "项目管理的数字化转型": [
            "从传统经验驱动到数据智能驱动",
            "从静态管理到动态实时优化",
            "从单一项目管理到企业级协同"
        ],
        "行业数据": [
            "全球83%的企业认为AI是项目管理的关键驱动力"
        ]
    }
)

# 4. 核心价值
create_content_slide(
    "核心价值：AI如何实现降本增效",
    {
        "1. 流程自动化": [
            "自动化重复性任务：数据录入、报表生成、合同审核等",
            "跨系统协同：打破信息孤岛，实现无缝对接",
            "案例数据：某金融机构贷款审批流程从5天压缩至8小时，效率提升87.5%"
        ],
        "2. 数据驱动决策": [
            "海量数据分析与洞察：挖掘隐藏在数据中的规律和机会",
            "预测性分析：需求预测、风险预警、资源需求规划",
            "案例数据：汽车零部件企业需求预测准确率从67%提升至89%，库存周转率提升40%"
        ],
        "3. 资源优化配置": [
            "人力资源：智能排班与任务分配，避免闲置或过度使用",
            "物资资源：库存优化与供应链协同，减少库存积压",
            "设备资源：预测性维护与高效利用，延长设备寿命"
        ],
        "4. 风险管理增强": [
            "实时监控与预警：及时发现潜在风险",
            "风险识别与评估：多维度分析风险影响",
            "案例数据：城商行小微企业贷款不良率降低0.8个百分点，节省风险成本3000万元"
        ]
    }
)

# 5. 行业实践
create_case_slide(
    "行业实践：多领域案例分析",
    {
        "制造业": [
            "智能供应链优化：库存周转天数从68天缩短至41天",
            "释放流动资金2.3亿元",
            "设备预测性维护：故障预测准确率提升至89%"
        ],
        "金融业": [
            "智能风控升级：整合8类政务数据，构建132个风险指标",
            "流程自动化：贷款审批效率提升80%",
            "客户满意度提高25%"
        ],
        "建筑行业": [
            "智慧工地管理：钢筋损耗率从15%降至8%",
            "年节约成本超千万元",
            "施工效率提升：工期压缩15天"
        ]
    }
)

# 6. 实施路径
create_content_slide(
    "实施路径：从规划到落地",
    {
        "1. 数据基建": [
            "数据清洗与标准化：处理5年历史订单数据，涵盖12类产品线、500+客户",
            "实时数据流整合：对接ERP/MES系统，实现数据实时更新",
            "构建包含18维特征的数据库"
        ],
        "2. 模型开发与训练": [
            "选择合适的AI技术：大模型、机器学习、RPA等",
            "行业知识融入与模型微调",
            "迭代优化机制：持续收集反馈，不断提升模型效果"
        ],
        "3. 系统集成与部署": [
            "与现有系统对接：开发API接口连接SAP系统",
            "分阶段试点与推广：先在单一业务线试点，成功后再全面推广",
            "开发动态看板实现可视化管理"
        ],
        "4. 人机协同机制": [
            "设定人工干预阈值：预测偏差超15%时触发人工干预",
            "员工培训与角色转型：帮助员工适应新工作模式",
            "建立反馈与优化闭环：持续收集用户反馈"
        ]
    }
)

# 7. 挑战与解决方案
create_challenge_solution_slide(
    "挑战与解决方案",
    {
        "数据质量与安全": "统一数据标准、实施数据治理、加密技术、严格权限管理",
        "技术与业务融合": "组建跨部门协作团队、业务导向的技术开发、建立共同目标",
        "成本投入与ROI评估": "分阶段投入、明确KPI指标、快速验证价值、长期规划",
        "员工抵触情绪": "透明沟通、提供培训支持、强调人机协作价值、重塑工作角色"
    }
)

# 8. 未来展望
create_content_slide(
    "未来展望",
    {
        "AI技术发展趋势": [
            "多模态AI的深度应用：融合文本、图像、语音等多种数据类型",
            "自主决策型项目管理系统：具备自我学习和优化能力",
            "行业大模型的定制化应用：针对特定行业场景的专用AI模型"
        ],
        "企业应用前景": [
            "可持续发展与ESG目标的AI支持：帮助企业实现绿色转型",
            "人机协作的新范式：AI成为人类的智能助手和合作伙伴",
            "全球化协作与智能化管理的深度融合"
        ]
    }
)

# 9. 总结页
create_summary_slide(
    "总结",
    [
        "AI不是取代人类，而是赋能人类，释放创造力",
        "降本增效的核心是数据驱动与流程优化的结合",
        "成功的关键在于技术与业务的深度融合，以及组织文化的变革",
        "未来已来，大型企业需抓住AI转型机遇，构建可持续竞争优势"
    ]
)

# 10. Q&A页
create_qa_slide("问答环节")

# 保存演示文稿
prs.save('AI降本增效_企业项目管理应用.pptx')
print("PPT生成完成！文件名为 'AI降本增效_企业项目管理应用.pptx'")